/*******************************************************************************
 * Copyright (c) 2011 Prometheus Consulting
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package nz.co.senanque.sandbox;

import java.io.File;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline.Argument;


/**
 * This is used for debugging XJC
 * -verbose -version -d ./generated ./sandbox.xsd
 * @author roger
 *
 */
public class XJCFacadeLauncher {

	/**
	 * @param args
	 */
	public static void main(final String[] args) {
//	    final String strClassPath = System.getProperty("java.class.path");
//	    System.out.println(strClassPath);
//		  try {
//			XJCFacade.main(args); // Simply delegates to the façade ;-) 
//		} catch (Throwable e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
		org.jvnet.jaxb2_commons.xjc.XJC2Task task = new org.jvnet.jaxb2_commons.xjc.XJC2Task();
		try
		{
            addArg(task,"-verbose");
            addArg(task,"-Xequals");
            addArg(task,"-Xmadura-objects");
            addArg(task,"-XtoString");
            addArg(task,"-Xannotate");
            addArg(task,"-Xvalidator");
            addArg(task,"-Xhyperjaxb3-ejb");
            
            Project project = new Project();
            project.setBasedir(".");

            task.setProject(project);
            task.setSchema("./sandbox.xsd");
            task.setExtension(true);
            task.setDestdir(new File("./generated"));
		    task.execute();
		}
		catch (Exception e)
		{
		    e.printStackTrace();
		}

	}
	private static void addArg(org.jvnet.jaxb2_commons.xjc.XJC2Task task, String command)
	{
        Argument arg = task.createArg();
        arg.setValue(command);
	}

}
